﻿@{
    ViewBag.Title = "OpenPopupChooseImage";
}
<h2>
    OpenPopupChooseImage</h2>
<form id="ImageForm" method="POST" enctype="multipart/form-data" action="/Book/submitImage">
<table>
    <tr>
        <td>
            Image:
        </td>
        @*Image*@
        <td>
            <input type="file" id="pic" name="pic" onchange="ImageChange();"/>
            @*<a href="#" onclick="getImage();">click to select image</a>*@
        </td>
    </tr>
</table>
</form>
<script type="text/javascript">
    function getImage() {
        $("#pic").click();
    }
    function ImageChange() {
        var fileName = document.getElementById("pic").value;
        if (fileName.indexOf(".jpg") != -1 || fileName.indexOf(".jpeg") != -1 || fileName.indexOf(".png") != -1) {
            document.forms["ImageForm"].submit();
        } else {
        alert("Please select image with ext is *.jpg or *.jpeg or *.png ");
        }
        
    }
</script>
